<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班组面板</title>
</head>
<body>
	<style type="text/css">
.insert_bt_rules {
	background: #CDDEF4;
}

.edContent table {
	width: 100%;
	table-layout: fixed;
}

.edContent span.lb {
	display: inline-block;
	padding-left: 10px;
	width: 120px;
	line-height: 20px;
	height: 20px;
	text-align: left;
	color: rgb(0, 0, 0);
	padding-right: 5px;
	border-bottom: 1px solid rgb(204, 204, 204);
}
</style>
	<div class="easyui-panel" id="ly-result-rules"
		data-options="
	border:false,
	fit:true,
	toolear:'#ly-insert_bt-rules'
">
		<div id="ly-insert_bt-rules" class="insert_bt_rules">
			<a class="easyui-linkbutton" 
				href="JavaScript:shqAddRules()"
				data-options="text:'添加',iconCls:'icon-save',plain:true"></a> 
			<a class="easyui-linkbutton" 
				href="JavaScript:shqupdateRules()"
				data-options="text:'编辑',iconCls:'icon-save',plain:true"></a> 
			<a
				href="JavaScript:lyReturnRules()" class="easyui-linkbutton return" iconCls="icon-reload"
				plain="true" title="返回" data-options="text:'返回'"></a> <span
				style="float: right; font-size: 12px; margin-top: 5px;">新增：考勤规则</span>
		</div>
		<script type="text/javascript">
			/* 返回 */
			var lyReturnRules = function(){
				$("#ly-result-rules").panel({
					href : "to_core_team"
				})
			}
			/* 新增 */
			var shqAddRules = function(){
				$("#ly-result-rules").panel({
					href : "to_core_teamadd"
				})
			}
			/* 编辑 */
			var shqupdateRules = function(){
				var teamId=$("#checkingRuleId").textbox("getText");
				$("#ly-result-rules").panel({
					href : "to_team_updates?teamId="+teamId
				})
			}
			
			/* 添加 */
			var lyAddRules = function(){
				//考勤规则
			/* 	var checkingRuleId = $("#checkingRuleId").textbox('getValue'); */
				var checkingRuleName = $("#checkingRuleName").textbox('getValue');
				var checkingRuleUp = $("#checkingRuleUp").val();
				var checkingRuleDown = $("#checkingRuleDown").val();
				
				var checkingkg = $("#ly-rules-checkingRuleKg").attr("checked");
				var isChecked ;
				if(checkingkg){
					isChecked=1;
				}else{
					isChecked=0;
				}
				//创建时间
				
				//备注
				var remark = $("#ly-checkingResult-remark").val();
				$("<form method='post'>").appendTo(document.body).form({
					url: 'checking/add_Rule_Results',
					onSubmit: function(params){
						//考勤规则
						/*  params["rule.checkingRuleId"] = checkingRuleId; */
						
						 params["rule.checkingRuleName"] = checkingRuleName;
						 params["rule.checkingRuleUp"] = checkingRuleUp;
						 params["rule.checkingRuleDown"] = checkingRuleDown;
						 params["rule.checkingRuleKg"] = isChecked;
						
						 params["rule.checkingRuleMarks"] = remark;
						//获取所有行（规则明细）
						var rows = $("#ly-result-rules-dg").datagrid("getRows");
						for(var i = 0; i < rows.length; i ++){
							
							params["result[" + i + "].ruleResultBegin"] = rows[i].ruleResultBegin;
							params["result[" + i + "].attribute841"] = rows[i].attribute841;
							params["result[" + i + "].attribute842"] = rows[i].attribute842;
							params["result[" + i + "].attribute843"] = rows[i].attribute843;
						}
					},
					success:function(v){
						v = eval("(" + v + ")");
						if(v.success){
							$.messager.alert('恭喜', '添加成功');
							//重定向
							$('#ly-result-rules').panel('open').panel('refresh','checking/to_checking_Rule');

							/* $("#ly-result-rules").panel({
								
									href : "checking/to_checking_Rule"
							}) */
							
						}else{
							$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
						}
					}
				}).submit();
				
			}
			
			

			
		</script>
		<div id="teamshet" class="easyui-panel"
		data-options="fit:true,border:false">
		<div
			style="margin: 5px; padding: 5px; border-bottom: 2px solid #2B91D5; width: 900px">
			概要</div>
		<table cellpadding="0" cellspacing="0"
			style="width: 1000px; table-layout: fixed; padding-left: 50px;">
			<tbody>

				<tr>
					<td style="width: 50%; vertical-align: top;">
						<div class="edContent">
							<table id="ct1" cellspacing="10" cellpadding="0" tag="A">
								<tbody>
									<tr>
										<td><span><em>*</em></span> <input class="easyui-textbox"
											id="checkingRuleId"
											name="checkingRuleId"
											data-options="label:'编号', width:280,labelWidth:60
											,readonly:true"  value='${tea.teamId}'
										 />
										</td>
									</tr>
									<tr>
										<td><span><em>*</em></span> <input class="easyui-textbox"
											id="checkingRuleName"
											value='${tea.teamName}'
											name="checkingRuleName"
											data-options="label:'名称', width:280,labelWidth:60,required:true" />
										</td>
									</tr>
									<tr>
										<td><span><em>*</em></span> <input class="easyui-textbox"
											id="defideName"
											value='${tea.definitionDept.defideName}'
											name="defideName"
											data-options="label:'部门名称', width:280,labelWidth:60,required:true" />
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</td>

					<td style="width: 50%; vertical-align: top;">
						<div class="edContent">
							<table id="ct1" cellspacing="10" cellpadding="0" tag="A">
								<tbody>
									<tr>
										<td><input id="statesone" value='${tea.teamTakeeffect}'class="easyui-datetimebox"
										data-options="label:'*生效时日', width:350,labelWidth:130" /></td>
									</tr>
									<tr>
										<td><input id="endtwe"value='${tea.teamLnvalid}' class="easyui-datetimebox"
										data-options="label:'*失效时日', width:350,labelWidth:130" /></td>
									</tr>
									<tr>
										<td><input class="easyui-textbox"
											id=""
											value='${tea.teamPerson}   ${tea.teamFounddate}'
											name=""
											data-options="label:'制单', width:350,labelWidth:130,required:true" />
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</td>
				</tr>

				<tr>
					<td colspan="3" style="width: 100%;">
				<tr>
			</tbody>
		</table>
		<script type="text/javascript">
			$(function(){
				
			})
		</script>
		<div
			style="margin: 5px; padding: 5px; border-bottom: 2px solid #2B91D5; width: 900px">
			员工列表</div>
		
	    <div data-options="region:'north', bodyCls:'bodyCls',border:false" style="height:40px,margin-bottom:24px;">
	    	<table width="990px">
	    		<tr>
					<td style="width: 25%"><input id="attruName"
						class="easyui-combobox"
						data-options="label:'规则结果',labelWidth:60,width:'80%',valueField:'attruId',textField:'attruName',editable:false,panelHeight:'auto',url:'checking/to_attendanceruleList'">
					</td>
					<td style="width: 25%"><input
						id="calculateRule"
						class="easyui-combobox"
						data-options="label:'计算规则',labelWidth:60,width:'80%',valueField:'calculateRuleId',textField:'calculateRuleName',editable:false,panelHeight:'auto',url:'checking/to_CalculateRuleList'"></td>

	    			<td style="width:25%">
	    			<input id="ruleResultBegin" class="easyui-combobox" data-options="label:'起点',labelWidth:60,width:'80%',
	    				valueField: 'ruleResultBegin',
						textField: 'value',
						panelHeight:'auto',
						editable:false,
	    				data: [{
								ruleResultBegin: '允许开始',
								value: '允许开始',
								selected:true
							},{
								ruleResultBegin: '开始',
								value: '开始'
							},{
								ruleResultBegin: '结束',
								value: '结束'
							},{
								ruleResultBegin: '允许结束',
								value: '允许结束'
							}
							]
	    				"></td>
	    			
	    			
	    		</tr>
	    		<tr>
	    			<td style="width:25%">
	    			<input id="attribute841" class="easyui-combobox"
						data-options="label:'偏移方向',
		    			labelWidth:60,
		    			width:'80%',
		    			valueField: 'attribute841',
						textField: 'value',
						panelHeight:'auto',
						editable:false,
	    				data: [{
								attribute841: '向前',
								value: '向前'
							},{
								attribute841: '向后',
								value: '向后',
								selected:true
							}
							]
	    			">
					</td>
	    			
	    			<td style="width:25%"><input id="attribute842" class="easyui-textbox" value="0" data-options="label:'偏移值',labelWidth:60,width:'80%'"></td>
	    			<td style="width:25%"><input id="attribute843" class="easyui-combobox" data-options="
		    			label:'偏移值类型',
		    			labelWidth:100,
		    			width:'80%',
		    			valueField: 'attribute843',
						textField: 'value',
						panelHeight:'auto',
						editable:false,
	    				data: [{
	    						
								attribute843: '分钟',
								value: '分钟',
								selected:true
							},{
								attribute843: '小时',
								value: '小时'
							}
							]
	    				
	    			"></td>
	    		</tr>
	    	</table>
	    </div>   
		<div id="ly-tb-rules-s" style="padding: 5px,margin: 5px">
			<a id="btn" href="JavaScript:lyAddRulesDetail()" class="easyui-linkbutton"
				data-options="iconCls:'icon-add'">添加员工</a> <a id="btn" href="JavaScript:lyDeleteRules()"
				class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">删除员工</a>
			<a id="btn" href="JavaScript:shqupdate()" class="easyui-linkbutton"
				data-options="iconCls:'icon-search'">编辑员工</a>
			<a id="btn" href="JavaScript:lyRemoveRules()" class="easyui-linkbutton"
				data-options="iconCls:'icon-search'">清空员工</a>
		</div>
		<script type="text/javascript">
			/* 添加规则 */
			var lyAddRulesDetail = function(){
				//获取当前页的数据
				//规则结果
				var attruName = $("#attruName").combobox("getText");
				//计算规则
				var calculateRule = $("#calculateRule").combobox("getText");
				var nameid = $("#calculateRule").combobox("getValue");
				//起点
				var ruleResultBegin = $("#ruleResultBegin").combobox("getText");
				//偏移方向
				var attribute841 = $("#attribute841").combobox("getText");
				//偏移值
				var attribute842 = $("#attribute842").textbox("getText");
				//偏移类型
				var attribute843 = $("#attribute843").textbox("getText");
			    $('#ly-result-rules-dg').datagrid("insertRow", {//这里还有一个index参数，可指定添加到某行。如果不写，默认为在最后一行添加
				    row: {
	                     code:attruName,
						 name:calculateRule,
						 ruleResultBegin:ruleResultBegin,
						 nameID:nameid,
						 attribute841:attribute841,
						 attribute842:attribute842,
						 attribute843:attribute843
						 
	                }                  
				});
			}
			
			/* 删除规则 */
			var lyDeleteRules = function(){
				//获取要选中的行
				var row = $("#ly-result-rules-dg").datagrid("getSelected");
				if(!row){
					$.messager.alert('提示', '没有选中要删除的行！');
					return;
				}
				$.messager.confirm('确认', '真的要删除吗？', function(v){
					if(v){
						//找到行对应的索引
						var rowIndex = $("#ly-result-rules-dg").datagrid("getRowIndex", row);
						//删除行
						 $("#ly-result-rules-dg").datagrid("deleteRow", rowIndex);
					}
				});
			}
			/* 清空规则 */
			var lyRemoveRules = function(){
				$.messager.confirm('警告','你确定要清空所有规则吗？',function(v){
					if(v){
						//获取所有的行
						var rows = $("#ly-result-rules-dg").datagrid("getRows");
						//循环遍历 一行行删除
						for(var i = rows.length - 1; i >= 0; i --){
							$("#ly-result-rules-dg").datagrid("deleteRow", i);
						}
					}
				})
				
			}
		</script>
		<table id="ly-result-rules-dg" class="easyui-datagrid" style="width: 900px; min-height:100px"
			data-options="
        	fitColumns:true,
        	singleSelect:true,
        	border:false,
        	toolbar: '#ly-tb-rules-s'
        ">
			<thead>
				<tr>
					<th data-options="field:'code',width:100">规则结果</th>
					<th data-options="field:'name',width:100">计算规则</th>
					<th data-options="field:'nameID',width:100,hidden:true">计算id</th>
					<th data-options="field:'ruleResultBegin',width:100,align:'left'">起点</th>
					<th data-options="field:'attribute841',width:100,align:'center'">偏移方向</th>
					<th data-options="field:'attribute842',width:100,align:'center'">偏移值</th>
					<th data-options="field:'attribute843',width:100,align:'center'">偏移值类型</th>
				</tr>
			</thead>
			
		</table>

		<div
			style="margin: 5px; padding: 5px; border-bottom: 2px solid #2B91D5; width: 900px">
			其他
		</div>
		<div style="margin: 5px">
		<input class="easyui-textbox"
			id="ly-checkingResult-remark"
			value='${tea.teamRemarks}'
			data-options="width:900,height:100,multiline:true" />
		</div>
	</div>
	</div>
</body>
</html>